package web;

import java.io.IOException;
import java.util.*;

import javax.servlet.*;
import javax.servlet.http.*;

import dao.*;
import entity.*;

public class PruefungLoeschenServlet extends HttpServlet {
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {

		long pruefungDbID = Long.parseLong(req.getParameter("pruefungDbID"));
		Pruefung pruefung = new PruefungDAO().load(pruefungDbID);
		req.setAttribute("pruefung", pruefung);

		req.getRequestDispatcher("PruefungLoeschen.jsp").forward(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {

		try {
			long pruefungDbID = Long
					.parseLong(req.getParameter("pruefungDbID"));

			new PruefungDAO().delete(pruefungDbID);
			resp.sendRedirect("LVAIndex");
		} catch (Exception e) {
			e.printStackTrace();
			resp.sendRedirect("ErrorPage");
		}

	}
}
